home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
gsdbloo.exe
/
DEMOR003.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-29
|
3KB
|
111 lines
program DemoR003;
{------------------------------------------------------------------------------
DBase Relational File Linkage
Relational Examples
Demo Program
Copyright (c) Richard F. Griffin
10 February 1992
102 Molded Stone Pl
Warner Robins, GA 31088
-------------------------------------------------------------
This unit demonstrates how to search for multiple records with a
common identifier.
The master file index is on the UNIQUEID field. The transaction
record places this unique identifier in the MASTERID field of the
transaction record.
The routine will read each master record and list all transactions
with the master record unique identifier.
-------------------------------------------------------------------------------}
uses
CRT,
GS_Date,
GS_FileH,
GS_KeyI,
GS_Strng,
GS_dBase,
GS_dBFld;
var
MstrFile : GS_dBFld_Objt;
TranFile : GS_dBFld_Objt;
ftest : file;
begin
ClrScr;
if not GS_FileExists(ftest, 'DEMOR1MF.DBF') then
begin
writeln('File DEMOR1MF.DBF not found. Run DEMOR001 to create.');
halt;
end;
if not GS_FileExists(ftest, 'DEMOR1TF.DBF') then
begin
writeln('File DEMOR1TF.DBF not found. Run DEMOR001 to create.');
halt;
end;
{The 'Real' example starts here}
MstrFile.Init('DEMOR1MF');
MstrFile.Open;
MstrFile.Index('DEMOR1ID');
TranFile.Init('DEMOR1TF');
TranFile.Open;
TranFile.Index('DEMOR1TN');
MstrFile.GetRec(Top_Record);
while not (MstrFile.File_EOF) and (GS_KeyI_Chr <> #27) do
begin
ClrScr;
{Display the master record}
Writeln('':37,'MASTER');
Writeln;
Writeln(' LASTNAME : ',MstrFile.FieldGet('LASTNAME'));
Writeln(' FIRSTNAME : ',MstrFile.FieldGet('FIRSTNAME'));
Writeln(' STREET : ',MstrFile.FieldGet('STREET'));
Writeln(' ADDRESS : ',MstrFile.StringGet('CITY'),', ',
MstrFile.FieldGet('STATE'),' ',
MstrFile.FieldGet('ZIP'));
{Display transaction information}
Writeln;
Writeln('':20,'-----------------------------------------');
Writeln('':34,'TRANSACTION');
Writeln;
{Hunt for matching records}
if TranFile.Find(MstrFile.FieldGet('UNIQUEID')) then
begin
while (MstrFile.FieldGet('UNIQUEID') = TranFile.FieldGet('MASTERID'))
and not TranFile.File_EOF do
begin
Writeln(TranFile.FieldGet('FULLNAME'),' ',
GS_Date_View(TranFile.DateGet('TRANDATE')),' ',
TranFile.FieldGet('AMOUNT'));
TranFile.GetRec(Next_Record);
end;
end
else Writeln('No Transaction Records!');
Writeln;
Writeln('Press Any Key to Continue: ') ;
Writeln('[ESC] Will Terminate the Program');
WaitForKey;
MstrFile.GetRec(Next_Record);
end;
MstrFile.Close;
TranFile.Close;
end.